'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  app.on('error', (err, ctx) => {
    console.log('请求发生错误' + JSON.stringify(err));
    // report error
  });
  app.on('request', ctx => {
    console.log('收到请求' + JSON.stringify(ctx.request));
    console.log('收到请求' + JSON.stringify(ctx.request.body));
    console.log('收到请求' + JSON.stringify(ctx.params));
    // log receive request
  });
  app.on('response', ctx => {
    // ctx.starttime is set by framework
    // const used = Date.now() - ctx.starttime;
    console.log('返回请求结果' + JSON.stringify(ctx.response));
    // log total cost
  });

  router.get('/front/getPosture', controller.front.getPosture);
  router.post('/front/addPosture', controller.front.addPosture);

  router.get('/side/getPosture', controller.side.getPosture);
  router.post('/side/addPosture', controller.side.addPosture);

  router.get('/person/front/getPosture', controller.personFront.getPosture);
  router.post('/person/front/addPosture', controller.personFront.addPosture);

  router.get('/person/side/getPosture', controller.personSide.getPosture);
  router.post('/person/side/addPosture', controller.personSide.addPosture);
  
  router.get('/getQiniuToken', controller.qiniu.getQiniuToken)
  // app.post('/addPosture', controller.home.addPosture);
};
